package sctu.edu.java.year2016.team07.shihaocheng.day20160520.chapter4_2;

/**
 * Created by admin on 2016/5/20.
 *用for循环打印菱形
 */

import java.util.Scanner;

public class chapter4_2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("please enter the length:");
        int Length = scan.nextInt();
        System.out.println("please enter the height:");
        int Height = scan.nextInt();
        if (Height % 2 == 0) {
            Height++;
        }
        if (Length % 2 == 0) {
            Length++;
        }
        for (int i = 0; i < Height / 2 + 1; i++) {

            for (int j = 0; j < Length + 1; j++) {
                if ((j - i) == Length / 2 || (j + i) == Length / 2) {
                    System.out.print("*");
                }
                else if ((j - i) != Length / 2 || (j + i) != Length / 2) {
                    System.out.print(" ");
                }

            }

            System.out.println();
        }
        for (int i = Height / 2 - 1; i >= 0; i--) {

            for (int j = 0; j < Length + 1; j++) {
                if ((j - i) == Length / 2 || (j + i) == Length / 2) {
                    System.out.print("*");
                }
                else if ((j - i) != Length / 2 || (j + i) != Length / 2) {
                    System.out.print(" ");
                }
            }

            System.out.println();

        }

    }
}